######## Functions for making container images (cpio, squashfs) ##########

from forest.api import get_tool

def mksquashfs(rootdir, outfile, compression = "default", compressargs = None):
    if compressargs is None:
        compressargs = []
    '''Make a squashfs image containing the given rootdir.'''
    if compression != "default":
        compressargs = ["-comp", compression] + compressargs
    return get_tool('system.execute')(["mksquashfs", rootdir, outfile] + compressargs)
